<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jscss.jsp"%>
<script type="text/javascript">
	
	var topicGrid = null;
	var topicDialog = null;
	$(function(){
		topicGrid = $("#topic_grid").ligerGrid({
                columns: [
				{ display: '主题ID', name: 'identifier', isSort : false, width: 250 ,
					render: function (record, rowindex, value, column){
						var html = '<a onclick="pictorialManage(\''+ value + '\',\''+ record.name + '\')" href="javascript:;">'+value+'</a>';
                		return html;
					}
				},
                { display: '主题名称', name: 'name', isSort : false, width: 250 },
                { display: '主题描述', name: 'description',isSort : false, width: 500 },
                { display: '状态', name: 'isLock', isSort : false, width: 50,
                	render:function(record, rowindex, value, column){
                		if(value){
                			return "屏蔽";
                		}else{
                			return "显示";
                		}
                	}	
                },
                {
                	display: '<a href="javascript:;" onclick="addTopic()">添加主题</a>', 
                	name: 'identifier',
                	isAllowHide: false, 
                	isSort : false,
                	width: 200,
					render: function (record, rowindex, value, column){
					//this     这里指向grid
					//record   行数据
					//rowindex 行索引
					//value    当前的值，对应record[column.name]
					//column   列信息
						var html = '<a onclick="editTopic(\''+ value + '\')" href="javascript:;">编辑</a>&nbsp;'; 
							//html+= '<a onclick="deleteTopic(\''+ value + '\')" href="javascript:;">删除</a>&nbsp;';
							//html+= '<a onclick="pictorialManage(\''+ value + '\',\''+ record.name + '\')" href="javascript:;">画报管理</a>&nbsp;'
							html+='&nbsp;<a onclick="move(\''+ value + '\',\'up\')" href="javascript:;">上移</a>';
							html+='&nbsp;<a onclick="move(\''+ value + '\',\'down\')" href="javascript:;">下移</a>';
							html+='&nbsp;<a onclick="move(\''+ value + '\',\'top\')" href="javascript:;">置顶</a>';
							return html; 
					}
                }
                ], 
                pageSize:10,
                root :'list',
                record:'totalRecord',
                url: "/misc/tag/topicGrid.htm", 
                width: '99%',height:'99%',
                fixedCellHeight : false
            });

	});
	
	function move(topicId,moveType){
		$.post("/misc/topic/movetopic.htm",{topicId:topicId,moveType:moveType},function(data){
			if(data=="success"){
				topicGrid.loadData();
			}
		})
	}
	//添加主题
	function addTopic(){
		topicDialog = $.ligerDialog.open({ height: 600,width:500, url: "/misc/tag/toPictorialTopicAdd.htm", isResize: false , showMax : true, modal:true,title:'添加主题'});
	}
	
	//编辑主题
	function editTopic(id){
		topicDialog = $.ligerDialog.open({ height: 600,width:500, url: "/misc/tag/toPictorialEdit.htm?id="+id, isResize: false , showMax : true, modal:true,title:'编辑主题'});
	}
	
	//删除主题
	function deleteTopic(id){
		$.ligerDialog.confirm('你真的要删除吗？', 
				function (yes){
					if(yes){
						$.post("/misc/tag/deletePictorialTopic.htm",{
							identifier : id
						},function(data){
							if(data=="success"){
								topicGrid.loadData();
								$.ligerDialog.success("删除成功");
							}else{
								$.ligerDialog.warn("由于系统抽经，刚才的操作不成功，请稍候再试");
							}
						});
					}
				});
	}
	//画报管理页面
	function pictorialManage(id, name){
		topicDialog = $.ligerDialog.open({ height: 800,width:1200, url: "/misc/tag/pictorialManage.htm?id="+id, isResize: false , showMax : true, modal:true,title:'画报管理('+name+")"});
	}
	
</script>

<div id="topic_grid" style="margin:0; padding:0"></div>

<%-- <table border="1" width="100%">
	<tr>
		<td style="color: red;width: 20%;">主题名称</td>
		<td style="color: red;width: 70%;">主题描述</td>
		<td style="color: red;width: 10%;"">操作</td>
	</tr>
	<c:forEach items="${ptList}" var="pt">
	<tr>
		<td>
			<a href="javascript:;" onclick="pictorialTopicTipShow(this)" lang="${pt.identifier}">${pt.name}</a>
		</td>
		<td>
			${pt.description}
		</td>
		<td>
			<a href="javascript:;" onclick="pictorialManage('${pt.identifier}')">画报管理</a>
		</td>
	</tr>
	</c:forEach>
</table>
<div id="edit_pictorial_topic"></div> --%>
